package com.hotelsystem.filter;

import org.apache.shiro.SecurityUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.logging.LogRecord;

public class MyFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    /*    // TODO Auto-generated method stub
        HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
        HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
        String requestUrl = httpRequest.getRequestURI().replace(httpRequest.getContextPath(), "");

        //
        if (!SecurityUtils.getSubject().isAuthenticated()) {
            if (null != httpRequest.getHeader("X-Requested-With") && httpRequest.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) {
                //在ajax响应头部设置一个sessionstatus状态，用于在ajax全局js(common.js)中判断
                httpResponse.setHeader("sessionstatus", "timeout");
                httpResponse.getWriter().print("timeout");//
                return;

            }
        }*/
        //System.out.println("这里输入了什么。。。。。。。");
        filterChain.doFilter(servletRequest, servletResponse);
    }
    @Override
    public void destroy() {

    }
}
